from Crypto.Cipher import AES
import base64

def decrypt_wx_data(encrypted_data, session_key, iv):
    # 解密算法
    key = base64.b64decode(session_key)
    iv = base64.b64decode(iv)
    cipher = AES.new(key, AES.MODE_CBC, iv)
    decrypted = cipher.decrypt(base64.b64decode(encrypted_data))
    decrypted_data = json.loads(decrypted[:-decrypted[-1]].decode('utf-8'))
    return decrypted_data

